package ru.msu.cmc.sp.oberon2;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.HashMap;
import ru.msu.cmc.sp.oberon2.*;

public class MethodSymbol extends Symbol {
	LinkedHashMap<String, Symbol> orderedArgs = new LinkedHashMap<String, Symbol>();
	public boolean variable = false;
	public InterAST tree = null;
	
	public MethodSymbol(String name, Type retType, Scope parent) {
        super(name, retType, parent);
    }
	
	public void setArgs(LinkedHashMap<String, Symbol> lhm) {
		orderedArgs = lhm;
	}
	public LinkedHashMap<String, Symbol> getMembers() { return orderedArgs; }
	
	public MethodSymbol clone() {
		MethodSymbol clone = new MethodSymbol(this.name, this.type, this.scope);
	    clone.variable = variable;
	    clone.tree = tree;
	    clone.orderedArgs = HashMapCloner.clone(orderedArgs);
		return clone;
	}
	
	public Scope getInnerScope() {
		Iterator iterator = orderedArgs.values().iterator();
		if (iterator.hasNext()) {
			return ((Symbol)iterator.next()).scope;
		}
		return null;
	}
}
